﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AzureGames.Domain.Models;

namespace AzureGames.Web.Models
{
    public class GameDefinitionListViewModel
    {
        public GameDefinitionListViewModel(IEnumerable<GameDefinition> games)
            : this(games, -1)
        { }

        public GameDefinitionListViewModel(IEnumerable<GameDefinition> games, int selectedId)
        {
            var selected = games.FirstOrDefault(x => x.ID == selectedId);
            Games = new SelectedItemList<GameDefinition>(games, selected);
            IsCollapsed = (selected != null);
        }

        public SelectedItemList<GameDefinition> Games { get; private set; }

        public GameDefinition SelectedGame
        {
            get { return Games.SelectedItem; }
        }

        public bool IsCollapsed { get; set; }
    }
}